package com.wd.health.view.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.wd.health.R;
import com.wd.health.model.bean.YpxqBean;
import com.wd.health.utils.RetrofitManager;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class YpxqActivity extends AppCompatActivity {

    private TextView tv_yp_name,tv_yp_ypcf,tv_yp_yyjj,tv_yp_gnzz,tv_yp_yfyl,tv_yp_ypxz,tv_yp_bzgg,tv_yp_blfy,tv_yp_zctj,tv_yp_zysx,tv_yp_pzwh;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ypxq);
        initView();
        initData();
    }

    private void initData() {
        Intent intent = getIntent();
        int id = intent.getIntExtra("id",0);
        String mName = intent.getStringExtra("name");
        tv_yp_name.setText(mName+"");
        RetrofitManager.getInstance().getYpxqData(id, new Observer<YpxqBean>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(YpxqBean ypxqBean) {
                YpxqBean.ResultBean result = ypxqBean.getResult();
                tv_yp_ypcf.setText(result.getComponent());
                tv_yp_yyjj.setText(result.getTaboo());
                tv_yp_gnzz.setText(result.getEffect());
                tv_yp_yfyl.setText(result.getUsage());
                tv_yp_ypxz.setText(result.getShape());
                tv_yp_bzgg.setText(result.getPacking());
                tv_yp_blfy.setText(result.getSideEffects());
                tv_yp_zctj.setText(result.getStorage());
                tv_yp_zysx.setText(result.getMindMatter());
                tv_yp_pzwh.setText(result.getApprovalNumber());
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    private void initView() {
        tv_yp_name = findViewById(R.id.tv_yp_name);
        tv_yp_ypcf = findViewById(R.id.tv_yp_ypcf);
        tv_yp_yyjj = findViewById(R.id.tv_yp_yyjj);
        tv_yp_gnzz = findViewById(R.id.tv_yp_gnzz);
        tv_yp_yfyl = findViewById(R.id.tv_yp_yfyl);
        tv_yp_ypxz = findViewById(R.id.tv_yp_ypxz);
        tv_yp_bzgg = findViewById(R.id.tv_yp_bzgg);
        tv_yp_blfy = findViewById(R.id.tv_yp_blfy);
        tv_yp_zctj = findViewById(R.id.tv_yp_zctj);
        tv_yp_zysx = findViewById(R.id.tv_yp_zysx);
        tv_yp_pzwh = findViewById(R.id.tv_yp_pzwh);
    }
}